<%@ page pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<!DOCTYPE html >
<html>
<head>
<meta charset="utf-8">
<title>Category</title>
</head>
<body>
	<h2>xem theo Category</h2>
	<form action="dothing.do" method="post">
	<table>
	<tr>
		<td>
			<div>NameProduct</div>
			<input type="text" name="nameproduct" value="${nameproduct}">
		</td>
		
		<td>
			<div>IdProduct</div>
			<input type="text" name="idproduct" value="${idproduct}">
		</td>
	
		<td>
			<div>Id</div>
			<input type="text" name="idcategory" value="${idcategory}">
		</td>
		
		<td>
			<div>Name</div>
			<input type="text" name="name" value="${name}">	
		</td>
		
		<td>
			<div>NameVN</div>
			<input type="text" name="namevn" value="${namevn}">
		</td>
		

		<td>
			<div>UnitPrice</div>
			<input type="text" name="unitprice" value="${unitprice}">
		</td>
		
	</tr>

		
	<tr>	
		<td>
			<div>Image</div>
			<input type="text" name="image" value="${image}">
		</td>
		
		<td>
			<div>ProductDate</div>
			<input type="text" name="productdate" value="${productdate}">
		</td>
		
		<td>
			<div>Available</div>
			<input type="text" name="available" value="${available}">
		</td>
		
		<td>
			<div>Quantity</div>
			<input type="text" name="quantity" value="${quantity}">
		</td>
		

	</tr>
	</table>
	<hr>
	<input type="submit" value="INSERT" name="btnInsert">
	<input type="submit" value="UPDATE" name="btnUpdate">
	<input type="submit" value="DELETE" name="btnDelete">
	<hr>
	
	</form>
	<table border="1">
		<tr>

			<th>NameProduct</th>
			<th>IdProduct</th>
			
			<th>Id</th>
			<th>Name</th>
			<th>NameVN</th>
			
			<th>UnitPrice</th>
			<th>Image</th>
			<th>ProductDate</th>
			<th>Available</th>
			<th>Quantity</th>
			<th>Edit</th>

		</tr>
		<c:forEach var="p" items="${plist}">
			<tr>
				<td>${p.getName()}</td>
				<td>${p.getId()}</td>
				
				<td>${p.getCate().getId()}</td>
				<td>${p.getCate().getName()}</td>
				<td>${p.getCate().getNameVN()}</td>
				
				<td>${p.getUnitPrice()}</td>
				<td>${p.getImage()}</td>
				<td>${p.getProductDate()}</td>
				<td>${p.getAvailable()}</td>
				<td>${p.getQuantity()}</td>
				<td><a href="dothing.do?edit=${p.getId()}&page=${currentPage}">Edit</a></td>

			</tr>
		</c:forEach>
	</table>
	
		<!-- Tham so vao currentPage / noOfPages -->
	 <c:if test="${currentPage != 1}">
        <td><a href="dothing.do?page=${currentPage - 1}">Previous</a></td>
    </c:if>
 
    <%--For displaying Page numbers.
    The when condition does not display a link for the current page--%>
    <table border="0" cellpadding="1" cellspacing="1">
        <tr>
            <c:forEach begin="1" end="${noOfPages}" var="i">
                <c:choose>
                    <c:when test="${currentPage eq i}">
                        <td>${i}</td> <!-- Trang hien tai thi ko can href -->
                    </c:when>
                    <c:otherwise>
                        <td><a href="dothing.do?page=${i}">${i}</a></td>
                    </c:otherwise>
                </c:choose>
            </c:forEach>
        </tr>
    </table>
     
    <%--For displaying Next link --%>
    <c:if test="${currentPage lt noOfPages}">
        <td><a href="dothing.do?page=${currentPage + 1}">Next</a></td>
    </c:if>
</body>
</html>